package com.qf.authcode;

import com.alibaba.fastjson.JSON;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.domain.AlipayTradeQueryModel;
import com.alipay.api.request.AlipayTradeQueryRequest;
import com.alipay.api.response.AlipayTradeQueryResponse;
import com.qf.mch.MchConfig;

public class QueryTest {
    public static final String orderNum = "202309261010002";
    public static void main(String[] args) throws AlipayApiException {

        AlipayClient alipayClient = new DefaultAlipayClient(MchConfig.serverurl, MchConfig.appid, MchConfig.privatekey, "json", "UTF-8", MchConfig.publickey, "RSA2");


        AlipayTradeQueryRequest req = new AlipayTradeQueryRequest();

        // 商户订单号，商户网站订单系统中唯一订单号，必填
        AlipayTradeQueryModel model = new AlipayTradeQueryModel();
        model.setOutTradeNo(orderNum);
        req.setBizModel(model);

        AlipayTradeQueryResponse response = alipayClient.execute(req);
        System.out.println(JSON.toJSONString(response));
    }
}
